package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.UserVocAISituationDTO;
import com.cskaoyan.wordmemorize.dto.admin.UserVocAISituationOptionDTO;
import com.cskaoyan.wordmemorize.dto.app.AIReviewReadDTO;
import com.cskaoyan.wordmemorize.request.AIReviewReadCommand;
import com.cskaoyan.wordmemorize.service.UserPrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



import java.util.List;

@RestController
@RequestMapping("user/priviledge/review/ai/read")
public class UserPriviledgeReviewAiReadController {

    @Autowired
    UserPrivilegeService userPrivilegeService;

    @PostMapping("")
    public Result<List<AIReviewReadDTO>> getAIReadReviewList(@RequestBody AIReviewReadCommand command) {
        Long userId = StpKit.USER.getLoginIdAsLong();
        List<AIReviewReadDTO> aiReviewReadDTO = userPrivilegeService.getAIReviewReadContent(command, userId);
        return Result.ok(aiReviewReadDTO);
    }
    @PostMapping("options")
    public Result<List<UserVocAISituationDTO>> getAIReviewReadOptions() {
        List<UserVocAISituationDTO> userVocAISituationDTOS = userPrivilegeService.getAIReviewReadOptions();
        return Result.ok(userVocAISituationDTOS);
    }
    @PostMapping("free")
    public Result<Integer> getUserVocAIReadRemainFreeCount() {
        Long userId = StpKit.USER.getLoginIdAsLong();
        Integer count = userPrivilegeService.getUserVocAIReadRemainFreeCount(userId);
        return Result.ok(count);
    }
}
